<template>
    <div class="dialog">
        <el-dialog 
          :title="dialog.title"
		  :close-on-click-modal="false"
		  :close-on-press-escape="false"
		  :modal-append-to-body="false"
		  :visible.sync="dialog.show">
            <el-form label-width="100px" :rules="rule">
			  <el-form-item label="标题：" prop="title">
			    <el-input v-model="title"></el-input>
			  </el-form-item>
			  <el-form-item label="内容：" prop="content">
			    <el-input v-model="content"></el-input>
			  </el-form-item>
              <el-form-item label="弹出次数：" prop="tanchucount">
			    <el-input v-model="tanchucount"></el-input>
			  </el-form-item>
              <el-form-item label="弹出选项：" prop="checkedtanchu">
                 <el-radio-group  v-model="checkedtanchu">
                    <el-radio-button  v-for="item in tanchutype" :key="item.label" :label="item.value"></el-radio-button>
                </el-radio-group>
            </el-form-item>
		  </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="handleClose()">取 消</el-button>
                <el-button type="primary" @click="handleAddAndEdit()">立即发送</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
    name:"Noticedialog",
    // 获取父亲传过来的值
    props:{
	    dialog:Object
	},
    data(){
        return{
            dialogVisible: false,
            checkedtanchu:"",
            title:"",
            content:"",
            tanchucount:"",
            tanchutype:[
                {
                    label:1,
                    value:'登录界面'
                },{
                    label:2,
                    value:'主界面'
                }
           ],
           rule:{
               checkedtanchu:[{require:true,trigger:'blur'}],
               title:[{require:true,message:"请输入标题",trigger:"blur"}]
           }
        }
    },
     methods: {
        handleAddAndEdit(){
             if(this.checked==2){
                 var obj={
                    title:this.title,
                    content:this.content,
                    tanchucount:this.tanchucount,
                    checkedtanchu:this.checkedtanchu
                }
                 this.$emit("update",obj)
            }else{
                var obj={
                    title:this.title,
                    content:this.content,
                    tanchucount:this.tanchucount,
                    checkedtanchu:this.checkedtanchu
                }
                 this.$emit("update",obj)
            }
            this.dialog.show=false
        },
        handleClose() {
            this.dialog.show=false
        }
    },
   
}
</script>
<style scoped>

</style>